package com.dk.enums;

public enum PositionEnum {

    QINGWUJIE(1, "秦无解"),
    S(2, "S级"),
    A(3, "A级"),
    B(4, "B级"),
    C(5, "C级");

    private final Integer code;
    private final String expr;

    PositionEnum(Integer code, String expr) {
        this.code = code;
        this.expr = expr;
    }

    public Integer getCode() {
        return code;
    }

    public String getExpr() {
        return expr;
    }

    //根据传入的code动态获取value
    public static String getExprByCode(Integer code) {
        if (null == code) {
            return null;
        }
        //获取所有枚举集合
        PositionEnum[] codeEnums = values();
        for (PositionEnum codeEnum : codeEnums) {
            if (codeEnum.getCode().equals(code)) {
                return codeEnum.getExpr();
            }
        }
        return null;
    }

}
